Passed
Pull Request — master (#2)
by Muhammad Dyas
02:13
created

response.ts ➔ buildActionResponse   A

Complexity

Conditions 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
c 0
b 0
f 0
rs 9.95
cc 1
1
/**
2
 * Creates an action response.
3
 * Action Response is parameter that a Chat app can use to configure how its
4
 * response is posted.
5
 * ref: https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#actionresponse
6
 *
7
 * @param {string} message - Number of votes for this option
8
 * @param {string} status - Status of
9
 * @returns {object} - ActionResponse
10
 */
11
export function buildActionResponseStatus(message: string, status = 'OK') {
12
  return {
13
    actionResponse: {
14
      type: 'DIALOG',
15
      dialogAction: {
16
        actionStatus: {
17
          statusCode: status,
18
          userFacingMessage: message,
19
        },
20
      },
21
    },
22
  };
23
}
24
25